//
//  MYWithdrawVC.m
//  MuYing
//
//  Created by tbb on 2019/8/10.
//  Copyright © 2019 TBB. All rights reserved.
//

#import "MYWithdrawVC.h"
#import "MYWithdrawBaseListVC.h"
#import <JXCategoryView/JXCategoryView.h>
@interface MYWithdrawVC ()<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate>
@property (nonatomic, strong) JXCategoryTitleView * categoryView;
@property (nonatomic, strong) JXCategoryListContainerView * listContainerView;
@property (nonatomic, copy) NSArray * titles;
@end

@implementation MYWithdrawVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = kYQLS(@"提现");
}

-(void)setupView {
    [super setupView];
    self.titles = @[kYQLS(@"银行提现"),kYQLS(@"PayPal提现")];
    self.categoryView = [[JXCategoryTitleView alloc] init];
    self.categoryView.delegate = self;
    self.categoryView.titles = self.titles;
    self.categoryView.defaultSelectedIndex = 0;
        self.categoryView.cellSpacing = 64;
    self.categoryView.titleSelectedColor = kAPPThemeColor;//HexColor(0x79C4C7);
    self.categoryView.titleColor = HexColor(0xA0A0A0);
    self.categoryView.titleFont = kSystemMedium(15);
    self.categoryView.titleSelectedFont = kSystemMedium(15);
    self.categoryView.contentEdgeInsetLeft = 12;
    self.categoryView.contentEdgeInsetRight = 12;
    self.categoryView.backgroundColor = UIColor.whiteColor;
    self.categoryView.titleColorGradientEnabled = YES;
    
    self.categoryView.averageCellSpacingEnabled = NO;
    
    JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
    
    lineView.indicatorColor = kAPPThemeColor;
    lineView.indicatorWidth = 32;
    lineView.indicatorHeight = 2.0;
    lineView.verticalMargin = 2;
    self.categoryView.indicators = @[lineView];
    
    [self.view addSubview:self.categoryView];
    
    self.listContainerView = [[JXCategoryListContainerView alloc] initWithDelegate:self];
    self.listContainerView.defaultSelectedIndex = 0;
    [self.view addSubview:self.listContainerView];
    
    self.categoryView.contentScrollView = self.listContainerView.scrollView;
}


- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    
    self.categoryView.frame = CGRectMake(0, 0, self.view.bounds.size.width, 44);
    
    self.categoryView.layer.shadowColor = HexColorA(0x000000, 0.6).CGColor;
    //2.设置阴影偏移范围
    self.categoryView.layer.shadowOffset = CGSizeMake(0, 2);
    //3.设置阴影颜色的透明度
    self.categoryView.layer.shadowOpacity = 0.07;
    
    //4.设置阴影半径
    self.categoryView.layer.shadowRadius = 4;
    //5.设置阴影路径
    self.categoryView.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.categoryView.bounds].CGPath;
    
    self.listContainerView.frame = CGRectMake(0, 48, self.view.bounds.size.width, self.view.bounds.size.height - 48);
}

#pragma mark - JXCategoryViewDelegate

- (void)categoryView:(JXCategoryBaseView *)categoryView didClickSelectedItemAtIndex:(NSInteger)index {
    [self.listContainerView didClickSelectedItemAtIndex:index];
}

- (void)categoryView:(JXCategoryBaseView *)categoryView scrollingFromLeftIndex:(NSInteger)leftIndex toRightIndex:(NSInteger)rightIndex ratio:(CGFloat)ratio {
    [self.listContainerView scrollingFromLeftIndex:leftIndex toRightIndex:rightIndex ratio:ratio selectedIndex:categoryView.selectedIndex];
}
#pragma mark - JXCategoryViewDelegate end
#pragma mark - JXCategoryListContainerViewDelegate

- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
    MYWithdrawBaseListVC *listVC = [[MYWithdrawBaseListVC alloc] init];
    listVC.balance = self.balance;
    [self addChildViewController:listVC];
    listVC.type = index;
    return listVC;
}

- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
    return self.titles.count;
}

#pragma mark - JXCategoryListContainerViewDelegate end

@end
